;;; $Id: fcgi.sld 226 2013-07-24 05:14:16Z alan.watson.f $

(define-library (oaxaca fcgi)

  (export main)

  (import (scheme base))
  (import (scheme read))
  (import (scheme write))
  (import (oaxaca eval))
  (import (only (chibi) print-exception))

  (begin

    (define (main)
      (call-with-current-continuation
       (lambda (k)
         (with-exception-handler
             (lambda (e)
               (display "Content-Type: text/plain; charset=utf-8\r\n\r\n")
               (print-exception e (current-output-port))
               (newline)
               (k))
           (lambda ()
             (let ((x (read)))
               (unless (eof-object? x)
                 (eval x))))))))))
